<?php
/**
*
* 程序处理文件
*
* @package  ShopEx网上商店系统
* @version  4.6
* @author   ShopEx.cn <develop@shopex.cn>
* @url		http://www.shopex.cn/
* @since    PHP 4.3
* @copyright ShopEx.cn
*
**/
if (!defined("ISSHOP"))
{
	Header("Location:../index.php");
	exit;
}
error_log(print_r($_POST,true),3,__FILE__.'.post.1.log');	//alone
foreach ($_POST as $k=>$v)
{
	$i = $k;	//中间变量 记录解密前的key
	$j = passport_decrypt($k,'alone');
	$_POST[$j] = passport_decrypt($v,'alone');
	unset($_POST[$i]);
}
error_log(print_r($_POST,true),3,__FILE__.'.post.2.log');	//alone

$item_name = substr($_POST['orderid'],5);	//订单ID
$mydate = substr($item_name,0,8);	//时间
$state = substr($_POST['state'],5);		//支付状态
if ($_POST['strinfo'] == 'alone')
{
	$strinfo = '';
}
else
{
	$strinfo = substr($_POST['strinfo'],5);	//支付信息
}
$signstr = substr($_POST['signstr'],5);	//标志符
$payment_amount = substr($_POST['amount'],5);		//支付金额
$payid = substr($_POST['payid'],5);		//支付ID
$payment_currency = substr($_POST['currency'],5);	//货币代号

$Order = newclass("Order");
$Order->updateOrderSign($item_name,$signstr);
if ($state == '2')
{	error_log(print_r('start',true),3,__FILE__.'.start.log');	//alone
	$Order->shopId = $INC_SHOPID;
	$Order->payid = $payid;		//支付流水号
	error_log(print_r($Order,true),3,__FILE__.'.Order1.log');	//alone
	$arr_paytime = getUnixtime($mydate);	//支付时间
	$Order->getbyId($item_name);		//拿出商店订单号
	error_log(print_r($Order,true),3,__FILE__.'.Order2.log');	//alone
	if ($item_name == "")
	{
		echo '订单号为空';
		exit;
	}
	if ($Order->paycur == $payment_currency && $Order->paymoney <= $payment_amount&& $Order->payid == $payid)
	{	error_log(print_r($Order,true),3,__FILE__.'.Order3.log');	//alone
		$Order->onlinePayed($arr_paytime[0], $arr_paytime[1]);
		error_log(print_r('test',true),3,__FILE__.'.test.log');	//alone
		$Order->getPayresult($item_name, $INC_SHOPID);
	}
}
?>
<html>
<head>
<title></title>
<meta http-equiv="refresh" content="0;url=<?php print "./index.php?gOo=pay_reply.dwt&orderid=".$item_name."&state=".$state."&strinfo=".$strinfo."&signstr=".$signstr?>">
</head>
<body>
</body>
</html>